<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
    File: PHPTAL
    PHPTAL is a Template Attribute Language based on ZPT
    
    This library wraps up the PHPTAL class and takes care of compilation
    directories and tales.
    
    Installation:
    - Download http://phptal.motion-twin.com/latest.tar.gz
    - Extract latest.tar.gz into the <ci-ext.libs_path>

    Note:
    An exception is thrown if the class can not be found.

    Copyright:
    PHPTAL is freely distributed under the LGPL license
    <http://opensource.org/licenses/lgpl-license.php>.
    
    It is developed and maintained by Laurent Bedubourg
    <lbedubourg@motion-twin.com>.
*/
 
$ci =& get_instance();

// if your not using PEAR you will need to set the include path so PHP can find 
// where you have PHPTAL.php
ini_set('include_path', $ci->config->item('libs_path')."/PHPTAL-1.1.8"
    .PATH_SEPARATOR.ini_get('include_path'));

try {
    // Set some constants for PHPTAL
    define('PHPTAL_FORCE_REPARSE', true);
    define('PHPTAL_PHP_CODE_DESTINATION', APPPATH.'/tmp/views/');
    
    require_once 'PHPTAL.php';
    
    if(!class_exists('PHPTAL')) {
        throw new Exception('PHPTAL Library was not found');
    }else{
    
        // Load the tails from shared and application directories
        $ci->load->helper('directory');
    
        $tales_dir_list = array(
            // list of directories to load php tales from
            $ci->config->item('libs_path').'/tales',
            APPPATH.'/libraries/tales'
        );
        
        foreach($tales_dir_list as $tales_dir) {
            // get a list of files in each directory
            $tales = directory_map($tales_dir);
            foreach($tales as $tale) {
                // include each one
                include_once $tales_dir.'/'.$tale;
            }
        }
    }
}
catch(Exception $e) {
    show_error($e->getMessage());
}

?>